TurboForth Data Sheet - F83 Compliant Word                         8th June 2011
       ______ ___ ____     _____                      _ _             _   
      |  ____/ _ \___ \   / ____|                    | (_)           | |  
      | |__ | (_) |__) | | |     ___  _ __ ___  _ __ | |_  __ _ _ __ | |_ 
      |  __| > _ <|__ <  | |    / _ \| '_ ` _ \| '_ \| | |/ _` | '_ \| __|
      | |   | (_) |__) | | |___| (_) | | | | | | |_) | | | (_| | | | | |_ 
      |_|    \___/____/   \_____\___/|_| |_| |_| .__/|_|_|\__,_|_| |_|\__|
                                               | |                        
                                               |_|                        
                       __          ______  _____  _____  
                       \ \        / / __ \|  __ \|  __ \ 
                        \ \  /\  / / |  | | |__) | |  | |
                         \ \/  \/ /| |  | |  _  /| |  | |
                          \  /\  / | |__| | | \ \| |__| |
                           \/  \/   \____/|_|  \_\_____/ 

The version of WORD built into the ROM of TurboForth is non standard.

TurboForth's WORD
-----------------
... works as follows:

WORD ( delimiter -- address length )
Moves through the Terminal Input Buffer (TIB), discarding leading delimiters, 
looking for a word. A word is identified when a trailing delimiter is detected.
If a word is identified:
* the start address of the word is pushed to the stack;
* the length of the word is pushed to the stack;
* >IN is adjusted to indicate the offset to the character following the 
  delimiter.

If a valid word is not identified, or the input stream is exhausted:
* the value of >IN is set to the size of the input stream (80 characters when 
  BLK=0 otherwise 1024 characters, as determined by the variable C/L).
  
#TIB is unmodified in both found/not found cases.



F83 standard behaviour of WORD
------------------------------
...is as follows:

WORD ( delimiter -- address )
Generates a counted string by non-destructively accepting characters from the 
input stream until the delimiting character "delimiter" is encountered or the 
input stream is exhausted.  Leading delimiters are ignored.  The entire
character string is stored in memory beginning at address as a sequence of
bytes. The string is followed by a blank which is not included in the count.  
The first byte of the string is the number of characters {0..255}.
If the string is longer than 255 characters, the count is unspecified.
If the input stream is already exhausted as WORD is called, then a zero length 
character string will result.           

If the delimiter is not found the value of >IN is the size of the input stream.  
If the delimiter is found >IN is adjusted to indicate the offset to the 
character following the delimiter.  #TIB is unmodified.


F83 Compliance:
---------------
It is possible to provide an F83 compliant version of WORD by wrapping the 
version of WORD provided in the ROM, as follows:

CREATE WBUF 80 CHARS ALLOT
: WORD
  WORD ?DUP IF 
    DUP WBUF C!  WBUF 1+ SWAP CMOVE
  ELSE 
    WBUF C! 
  THEN 
  32 WBUF C@  WBUF + 1+ C!
;

This version places the extracted string into the buffer WBUF. Obviously, the
size of WBUF can be adjusted to suit ones requirememts.


The principal difference between the two routines is that the TF ROM version
does *not* copy the identified word to another place, as the standard implies
via the use of the word "generates". TF's WORD returns an address and length to
the identified word in-situ. This obviates the need for additional word buffers,
saving valuable memory.